#pragma once

#include "loirey_BasicStructure.h"
#include "loirey_MyMath.h"
#include "loirey_Normalizer.h"

namespace loirey
{
	class CSparseVector
	{
	public:
		int Length;
		CSimpleTypeArray<int> IndexList;
		CSimpleTypeArray<double> ValueList;

	public:
		CSparseVector();
	public:
		static size_t GetIVPairMemorySize();
	public:
		virtual size_t GetVectorMemorySize() const;
		virtual void WriteToFile(FILE* FOUT) const;
		virtual void ReadFromFile(FILE* FIN);
	public:
		virtual void myInit(const CSimpleTypeArray<double>& DenseValueList);
		virtual void myInit(const CSparseVector& Another);
		virtual void myInit(const CSimpleTypeArray<int>& IndexList, const CSimpleTypeArray<double>& ValueList);
	public:
		virtual void Clear();
		virtual void PushBack(int Index, double Value);
		virtual void SortByIndex();
		virtual void SortByValue();
	public:
		virtual void DeepClear();
		virtual void Swap(CSparseVector& Another);
		virtual void Normalize(CMyNormalizer* pNormalizer);
	public:
		virtual double GetValue(int Index) const;
	};

}

